package maple.core;

import java.util.logging.Level;
import java.util.Vector;

import jade.domain.DFService;
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAException;

public abstract class Producer extends MapleAgent
{
	protected Vector< String > _names;
	protected Vector< String > _types;

	public Producer()
	{
		super();

		_names = new Vector< String >();
		_types = new Vector< String >();
	}

	/**
	 * de-register services
	 *
	 * @author	snowfoxy
	 * @since	2011-12-18
	 */
	protected void deregister()
	{
		try
		{
			DFService.deregister( this );
		}
		catch( FIPAException e )
		{
			_logger.log( Level.WARNING, "", e );
		}
	}

	/**
	 * register services withe the specified names and types
	 *
	 * @author	snowfoxy
	 * @since	2011-12-18
	 */
	protected void register()
	{
		try
		{
			DFService.register( this, getInstance( _names, _types, null, null, null ) );
		}
		catch( FIPAException e )
		{
			_logger.log( Level.WARNING, "", e );
			doDelete();
		}
	}
}
